/**
 * Copyright (C) 2009 IcyRiver / Wesley He
 *
 * IcyRiver Lib  may be copied only under the terms of the GNU General
 * Public License V1, which may be found in the IcyRiver.net source kit.
 * Please visit the IcyRiver Home Page http://icyriver.net/ for more detail.
 **/

//thread_daemon.c

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

#include <stdlib.h>
#include <pthread.h>

#include "thread_daemon.h"
#include "thread.h"

int main(int argc, char *argv[])
{

	int result;
	pthread_mutex_t g_thread_lock;
	pthread_t tids;
	void *thread_arg;

	/*
	   if ((result=g_thread_init_pthread_lock( &g_thread_lock)) != 0)
	   {
	   return result;
	   }
	 */

	result = 0;
	if ((result=g_thread_create_work_threads(NULL, g_thread_entrance, thread_arg, &tids)) != 0)
	{
		return result;
	}
	else
	{
#ifdef __DEBUG__
		fprintf(stderr,"file: %s, line: %d:thread_daemon is ending ....\n",\
				__FILE__, __LINE__);
#endif
		pthread_exit("exit\n");
		return 0;
	}
}
